package cn.tedu.spring.begin;

import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ruoLi
 */
public class UserTest {
    BeanDefinitionReader reader;
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        /**
         * 方式1
         * 1.加载spring配置文件(bean.xml)
         * 2.获取spring创建好的对象
         * 3.测试打印(调用add方法)
         */
        ApplicationContext application = new ClassPathXmlApplicationContext("bean.xml");
        User user = (User) application.getBean("user");
        user.add();
        /**
         * 方式2 new方式创建java对象
         *
         */
        User user2=new User();
        user2.add();
        /**
         * 方式3 反射方式创建java对象
         * 1.获取类对象
         * 2.调用方法进行创建
         */
        Class zz = Class.forName("cn.tedu.spring.begin.User");
        User user3 =(User) zz.newInstance();
        user3.add();

    }
}
